<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>用户列表</title>
</head>
<script src="https://cdn.bootcss.com/jquery/2.2.4/jquery.min.js"></script>

<!--<link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">-->
<script src="js/bootstrap.js"></script>
<!--<link rel="stylesheet" href="css/gameStyle2.css" type="text/css">-->

<link href="assets/css/lib/font-awesome.min.css" rel="stylesheet" type="text/css" >
<link href="assets/css/lib/themify-icons.css" rel="stylesheet" type="text/css">
<link href="assets/css/lib/owl.carousel.min.css" rel="stylesheet" type="text/css"/>
<link href="assets/css/lib/owl.theme.default.min.css" rel="stylesheet" type="text/css"/>
<link href="assets/css/lib/weather-icons.css" rel="stylesheet" type="text/css"/>
<link href="assets/css/lib/mmc-chat.css" rel="stylesheet" type="text/css"/>
<link href="assets/css/lib/sidebar.css" rel="stylesheet" type="text/css">
<link href="assets/css/lib/bootstrap.min.css" rel="stylesheet" type="text/css">
<link href="assets/css/lib/simdahs.css" rel="stylesheet" type="text/css">
<link href="assets/css/style.css" rel="stylesheet" type="text/css">

<title>添加商品</title>

<body >




<div class="sidebar sidebar-hide-to-small sidebar-shrink sidebar-gestures">
    <div class="nano">
        <div class="nano-content">
            <ul>
                <li class="label">主页</li>
                <li ><a href="admin.jsp"><i class="ti-home"></i> 控制面板 </a></li>
                <li><a href="userList.html"><i class="ti-user"></i> 用户管理</a></li>
                <li ><a href="findAllGameByPage"><i class="ti-palette"></i> 游戏管理</a></li>
                <li  class="active"><a href="userList.html"><i class="ti-pencil-alt"></i> 评论管理</a></li>
                <li ><a href="findAllLibraryByPage"><i class="ti-user"></i> 用户游戏库管理</a></li>
                <li ><a href="articleList.html"><i class="ti-book"></i> 文章管理</a></li>
            </ul>
        </div>
    </div>
</div>
<div class="header">
    <div class="pull-left">
        <div class="logo" id="sideLogo">
            <a href="index.html">
                <img class="full-logo" src="assets/images/logo-big.png" alt="SimDahs">
                <img class="small-logo" src="assets/images/logo-small.png" alt="SimDahs">
            </a>
        </div>
        <div class="hamburger sidebar-toggle">
            <span class="ti-menu"></span>
        </div>
    </div>

    <div class="pull-right p-r-15">
        <ul>



            <li class="header-icon dib"><img class="avatar-img" src="assets/images/avatar/1.jpg" alt="" /> <span class="user-avatar">王德发 <i class="ti-angle-down f-s-10"></i></span>

            </li>
        </ul>
    </div>
</div>

<div   class="container-fluid" style="width: 80% ;margin: 0 auto 0 300px;">

    <div class="card-body" style="margin-top: 80px">
        <h1 id="h1" style="text-align: center">用户列表</h1>
<table  class="table table-responsive table-hover"> <!-- Replace "table-1" with any of the design numbers -->
    <thead>
    <th>id</th>
    <th>名字</th>
    <th>评论时间</th>
    <th>评论内容</th>
    <th>删除评论</th>
    </thead>
    <tbody id="userList">


    </tbody>
</table>
    </div>
<div style="width: 200px;margin: 20px auto;">
    <button id="prePage" class="btn btn-info btn-rounded m-b-10 m-l-5">上一页</button>
    <button id="currentPage" class="btn btn-danger btn-rounded m-b-10 m-l-5">1</button>
    <button id="nextPage" class="btn btn-info btn-rounded m-b-10 m-l-5">下一页</button>
</div>
</div>



</body>
<script>
    var currentPage = 1;
    var total,pageSize,totalPage;
    pageSize = 7;
    $(function () {
        $.ajax({
            url:'count',
            type:'text',
            success:function (data) {
                console.log(data);
                if (data%pageSize === 0){
                    totalPage = data/pageSize;
                }else {
                    totalPage = Math.ceil(data/pageSize);
                }

                console.log(totalPage)
            }
        })
    });

    $(function () {
        $.ajax({
            type: 'post',
            url: "showCommentsToAdmin",
            //data:{'pageNum':1,'size':1},
        }).success(function (data) {
             console.log(data);
            var ll = "";
            for (var i in  data){
                console.log(data[i][1]);
                ll += "<tr>";
                ll += "<td>"+data[i][0]+"</td>" +
                    "<td>"+data[i][4]+"</td>" +
                    "<td>"+data[i][2]+"</td>"+
                    "<td>"+data[i][1]+"</td>"+
                    "<td><a class='btn btn-info btn-flat btn-addon m-b-10 m-l-5' href='delComments?cid="+data[i][0]+"'><i class='ti-close'></i>删除</a> </td>";
                ll += "</tr>";
            }

            document.getElementById("userList").innerHTML = ll;
            //console.log(ll)

        }).error(function () {
            alert("上传失败");
        });

    });

    function getData(page) {
        $.ajax({
            type: 'post',
            url:'userList',
            data:{'pageNum':page,'size':pageSize},
            dataType:'json',

        }).success(function (data) {
            console.log('执行成功');
            console.log(data);
            $("#userList").empty();
            $("#currentPage").empty();
            $("#currentPage").append(currentPage);
            //$('#trr').append('<td id="name"></td>');
            //$('#trr').append('<td id="address"></td>');
            $.each(data,function (i,j) {
                //console.log(j.name);
                $("#userList").append('<tr id="tr'+i+'"></tr>');
                $('#tr'+i).append(
                    '<td id="id'+i+'"></td>'+
                    '<td id="name'+i+'"></td>'+
                    '<td id="time'+i+'"></td>'+
                    '<td id="money'+i+'"></td>' +
                    '<td id="option'+i+'"></td>');
                $('#id'+i).append(j[0]);
                $('#name'+i).append(j[4]);
                $('#time'+i).append(j[2]);
                $('#comtext'+i).append(j[1]);
                $('#option'+i).append("<a class='btn btn-info btn-flat btn-addon m-b-10 m-l-5' href='delComments?cid="+data[i][0]+"'><i class='ti-close'></i>删除</a> ");
                console.log(i);
                console.log(j)
            })
        })
    }
    //上一页
    $('#prePage').click(function(){
        console.log('点击了上一页');
        currentPage = currentPage -1;
        if(currentPage>=1){
            console.log(currentPage);
            getData(currentPage);
        }else{
            currentPage = 1;
        }
        return false;
    });

    //下一页
    $("#nextPage").click(function(){
        console.log('点击了下一页');
        currentPage = currentPage +1;
        if(currentPage<=totalPage){
            console.log(currentPage);
            getData(currentPage);
        }else{
            currentPage = totalPage;
        }
        return false;
    });


</script>
<script type="text/javascript" src="assets/js/lib/jquery.min.js"></script><!-- jquery vendor -->
<script type="text/javascript" src="assets/js/lib/jquery.nanoscroller.min.js"></script><!-- nano scroller -->
<script type="text/javascript" src="assets/js/lib/sidebar.js"></script><!-- sidebar -->
<script type="text/javascript" src="assets/js/lib/bootstrap.min.js"></script><!-- bootstrap -->
<script type="text/javascript" src="assets/js/lib/mmc-common.js"></script>
<script type="text/javascript" src="assets/js/lib/mmc-chat.js"></script>
<!--  Chart js -->
<script type="text/javascript" src="assets/js/lib/chart-js/Chart.bundle.js"></script>
<script type="text/javascript" src="assets/js/lib/chart-js/chartjs-init.js"></script>
<!-- // Chart js -->


<script src="assets/js/lib/sparklinechart/jquery.sparkline.min.js"></script><!-- scripit init-->
<script src="assets/js/lib/sparklinechart/sparkline.init.js"></script><!-- scripit init-->

<!--  Datamap -->
<script src="assets/js/lib/datamap/d3.min.js"></script>
<script src="assets/js/lib/datamap/topojson.js"></script>
<script src="assets/js/lib/datamap/datamaps.world.min.js"></script>
<script src="assets/js/lib/datamap/datamap-init.js"></script>
<!-- // Datamap -->
<script src="assets/js/lib/weather/jquery.simpleWeather.min.js"></script>
<script src="assets/js/lib/weather/weather-init.js"></script>
<script src="assets/js/lib/owl-carousel/owl.carousel.min.js"></script>
<script src="assets/js/lib/owl-carousel/owl.carousel-init.js"></script>
<script src="assets/js/scripts.js"></script>
</html>